home *** CD-ROM | disk | FTP | other *** search
/ Network CD 1 / Network CD.iso / tbag / 1-10 / tb1 / arc-files / newtopaz.arc / test.c < prev    next >
C/C++ Source or Header  |  1986-10-06  |  3KB  |  107 lines

  1. #include <exec/ports.h>
  2. #include <exec/nodes.h>
  3. #include <exec/types.h>
  4. #include <exec/exec.h>
  5. #include <intuition/intuition.h>
  6. #include <intuition/intuitionbase.h>
  7. #include <graphics/gfxbase.h>
  8. #include <graphics/gfx.h>
  9. #include <graphics/text.h>
  10. #include <graphics/regions.h>
  11. #include <graphics/copper.h>
  12. #include <graphics/gels.h>
  13. #include <devices/serial.h>
  14. #include <devices/keymap.h>
  15. #include <hardware/blit.h>
  16. #include <stdio.h>
  17. #include <ctype.h>
  18. #include <libraries/dos.h>
  19. #include <libraries/dosextens.h>
  20. #include <devices/timer.h>
  21. #include <exec/libraries.h>
  22.  
  23.  
  24.  
  25. /* 
  26.     -------------------------------------------
  27.     Eric's macros, makes C into modern language 
  28.     function is null - used so we have an easy 
  29.         way to search for functions 
  30.     -------------------------------------------
  31. */
  32. #define function
  33. #define then {
  34. #define els } else {
  35. #define fi }
  36. #define rof }
  37. #define elsif } else if
  38. #define or ||
  39. #define and &&
  40. #define z if (0==1)
  41.  
  42. struct DiskfontBase       *DiskfontBase;
  43. struct GfxBase            *GfxBase;
  44. extern long               *OpenLibrary();
  45. extern struct TextFont    *OpenDiskFont();
  46.  
  47. function main (argc,argv) int argc; char **argv;  {
  48.     struct TextFont *fontptr;
  49.     static struct TextAttr ericfont = {(STRPTR)"ericbd.font",8L,0L,0L};
  50.     
  51.     long int ecode = 0; 
  52.     struct Message *m1;  /* travel thru structures to the name */
  53.     struct Node    *n1;
  54.     char           *c1; 
  55.  
  56.     if (argc < 2 ) then
  57.         printf("Usage: %s fontname\n",argv[0]);
  58.         exit(20l);
  59.     els
  60.         ericfont.ta_Name = (STRPTR) argv[1];
  61.     fi
  62.     printf("replace topaz.font with |%s|\n",argv[1]);
  63.  
  64.     DiskfontBase = (struct DiskfontBase *) OpenLibrary("diskfont.library",0L);
  65.     if ( DiskfontBase == NULL) then
  66.         printf("can't open disk font library\n");
  67.         ecode = 20L;
  68.         goto  exiter;
  69.     fi
  70.  
  71.     GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",0L);
  72.     if ( GfxBase == NULL) then
  73.         printf("can't open graphics library\n");
  74.         ecode = 21L;
  75.         goto  exiter;
  76.     fi
  77.     
  78.     fontptr = (struct TextFont *) OpenDiskFont(&ericfont); 
  79.     if (fontptr == 0) then
  80.            printf("can't open font\n");
  81.         ecode = 21L;
  82.         goto  exiter;
  83.     fi
  84. /*  printf("gfxbase = %08lx   %08lx\n",GfxBase,&GfxBase->TextFonts);        */
  85. /*  printf("gfxbase = %08lx   %08lx\n",GfxBase,&GfxBase->DefaultFont);      */
  86. /*  printf("fontptr = %08lx   %08lx\n",fontptr,GfxBase->TextFonts.lh_Head); */
  87.  
  88.     GfxBase->TextFonts.lh_Head  = (struct Node *) fontptr;
  89.     m1 = &fontptr->tf_Message;  /* find name of our font */
  90.     n1 = &m1->mn_Node;
  91.     c1 = n1->ln_Name;        /* address of string into c1 */
  92.     
  93. /*  printf("m1 = %08lx n1 = %08lx c1 = %08lx\n",m1,n1,c1);  */
  94.     GfxBase->DefaultFont = fontptr;
  95.     movmem("topaz.font",c1,(short)11); /* overwrite name of ericbd.font */
  96.     ecode = 0;
  97.     goto exiter;
  98.  
  99.  
  100. exiter:
  101. /*      if (fontptr)      CloseFont(fontptr);          leave open forever */
  102.       if (DiskfontBase) CloseLibrary(DiskfontBase);
  103.       if (GfxBase)      CloseLibrary(GfxBase);
  104.       exit(ecode);
  105. }
  106.  
  107.